import Vue from 'vue';
import Vuex from 'vuex';
import {storageLocal} from '@/common/utils/storage';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        user: {},
        menus: [],
        roles: [],
        buttons: {},
    },
    mutations: {
        setUser(state, payload){
            state.user = payload;
        },
        setMenus(state, payload){
            state.menus = payload;
        },
        setRoles(state, payload){
            state.roles = payload;
        },
        setButtons(state, payload){
            state.buttons = payload;
        },
    },
    actions: {
        initStates({commit}){
            commit('setUser', {});
            commit('setMenus', []);
            commit('setRoles', []);
            commit('setButtons', {});
            storageLocal.del('role');
        }
    },
    modules: {},
});
